import { ApiModelProperty } from "@nestjs/swagger"

import { prop } from "@typegoose/typegoose"
import { AttributeTyps } from "../../../../apps/admin/src/categories/AttributeTyps.enum"
import { StringOrObject } from "../../../../apps/admin/src/categories/StringOrObject.enum"
import { IsNotEmpty } from "class-validator"

export class Attribute {
  @ApiModelProperty({ description: '属性名称', example: 'name' })
  @prop()
  @IsNotEmpty({ message: '属性名称不可缺少' })
  name!: string
  
  @ApiModelProperty({ description: '输入标签种类', enum: AttributeTyps })
  @prop()
  @IsNotEmpty({ message: '属性对应输入标签种类不可为空' })
  type!: AttributeTyps
  
  @ApiModelProperty({ description: '字符串, 数字或者对象', enum: StringOrObject, required: false })
  @prop()
  messageType?: StringOrObject
  
  @ApiModelProperty({ description: `字符串或者是字符串数组 字符串对应文本输入框 字符数组对应选择框的选择集`, type:  [String], required: false })
  @prop()
  message?: string | string[]

  @ApiModelProperty({ description: `和 message 数值类型上无实质区别, value 展示要展示的实际值, 比如尺码有['x','xl','ll'], 实际商品存货只有['x','xl'] 此值用于具体商品的新增的 attribute`, type:  [String], required: false })
  @prop()
  value?: string | string[]
}